home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / CERTRQXT.AS_ / certrqxt.asp
Encoding:
Text File  |  2003-02-21  |  16.1 KB  |  446 lines

  1. ∩╗┐<%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certrqxt.asp - (CERT)srv web - (R)e(Q)uest, e(XT)ernally created
  3.   ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <%
  7.     Dim sBrowserDependentLineBreak
  8.     If "Text"<>sBrowser Then
  9.         sBrowserDependentLineBreak="<BR>"
  10.     Else
  11.         sBrowserDependentLineBreak=""
  12.     End If
  13. %>
  14. <HTML>
  15. <Head>
  16.     <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  17.     <Title>Microsoft Certificate Services</Title>
  18. </Head>
  19. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF OnLoad="postLoad();"><Font ID=locPageFont Face="Arial">
  20.  
  21. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  22. <TR>
  23.     <TD><Font Color=#FFFFFF><LocID ID=locMSCertSrv><Font Face="Arial" Size=-1><B><I>Microsoft</I></B> Certificate Services  --  <%=sServerDisplayName%>  </Font></LocID></Font></TD>
  24.     <TD ID=locHomeAlign Align=Right><A Href="/certsrv"><Font Color=#FFFFFF><LocID ID=locHomeLink><Font Face="Arial" Size=-1><B>Home</B></Font></LocID></Font></A></TD>
  25. </TR>
  26. </Table>
  27.  
  28. <Form Name=UIForm OnSubmit="goNext();return false;" Action="certlynx.asp" Method=Post>
  29. <Input Type=Hidden Name=SourcePage Value="certrqxt">
  30.  
  31. <P><LocID ID=locPageTitle> <B> Submit a Certificate Request or Renewal Request</B></LocID>
  32. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  33.  
  34. <%If "IE"=sBrowser Then%>
  35. <Span ID=spnFixTxt Style="display:none">
  36.     <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000"><TR><TD><LocID ID=locBlankError>
  37.         <I>The request field may not be left blank.</I> Please paste a request in the field and try again.
  38.     </TD></LocID></TR></Table>
  39. </Span>
  40. <%End If%>
  41.  
  42. <P><LocID ID=locInstructions>
  43. To submit a saved request to the CA, paste a base-64-encoded CMC or PKCS #10 
  44. certificate request or PKCS #7 renewal request generated by an 
  45. external source (such as a Web server) in the Saved Request box.</LocID>
  46. </P>
  47.  
  48. <Table Border=0 CellSpacing=0 CellPadding=0>
  49.     <TR> <!-- establish column widths. -->
  50.         <TD><Img Src="certspc.gif" Alt="" Height=1 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  51.         <TD RowSpan=59><Img Src="certspc.gif" Alt="" Height=1 Width=4></TD>                <!-- label spacing column -->
  52.         <TD></TD>                                                                          <!-- field column -->
  53.     </TR>
  54.     
  55.     <TR>
  56.         <TD ColSpan=3><Font Face="Arial" Size=-1><Label For=locTaRequest><LocID ID=locSavedReqHead><B>Saved Request:</B></LocID></Label></Font></TD>
  57.     </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  58.     </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD></TR>
  59.         
  60.     <TR>
  61.         <TD Align=Left><Span ID=spnPasteLabel><LocID ID=SavedReqLabel><Font Face="Arial" Size=-1>Base-64-encoded 
  62.         <%=sBrowserDependentLineBreak%> certificate request
  63.         <%=sBrowserDependentLineBreak%> (CMC or
  64.         <%=sBrowserDependentLineBreak%>  PKCS #10 or
  65.         <%=sBrowserDependentLineBreak%>  PKCS #7):</Font></LocID></Span></TD>
  66.         <TD><TextArea ID=locTaRequest Rows=6 Cols=40 Name=taRequest Wrap=Off></TextArea></TD>
  67.     </TR><TR><TD ColSpan=3 Height=3></TD>
  68.     </TR><TR><TD></TD>
  69.         <TD><%If "IE"=sBrowser Then%>
  70.         <LocID ID=locBrowse><Font Face="Arial" Size=-1><Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  71.             OnContextMenu="return false;"
  72.             OnKeyDown="if (13==event.keyCode) {BeginRead();blur();return false;} else if (9==event.keyCode) {return true;};return false;"
  73.             OnClick="BeginRead();blur();return false;"
  74.             OnMouseOver="window.status=L_BrowseLink_Message;return true;" 
  75.             OnMouseOut="window.status='';return true;">Browse for a file to insert</Span>.
  76.         </Font></LocID>
  77.         <Span ID=spRead Style="display:none">
  78.         <Table Border=0 CellSpacing=0 CellPadding=0>
  79.         <TR><TD Height=5></TD>
  80.         <TR>
  81.             <TD Width=6></TD>
  82.             <TD Width=3 BgColor=#008080></TD>
  83.             <TD Width=4></TD>
  84.             <TD>
  85.                 <LocID ID=locFileNameLabel>Full path name:</LocID> <Input ID=locFlRequest Type=File Size=40 Name=flRequest><BR>
  86.                 <Input ID=locBtnRead Type=Button Value="Read!" onClick="FinishRead();blur();" Style="font-weight:bold">
  87.                 <Input ID=locBtnCancel Type=Button Value="Cancel" onClick="spRead.style.display='none';blur();">
  88.  
  89.             </TD>
  90.         </TR>
  91.         </Table>
  92.         </Span>
  93.         <%End If%></TD>
  94.     </TR>     
  95.  
  96.     <%If "Enterprise"=sServerType Then%>
  97.     <TR>
  98.         <TD ColSpan=3><LocID ID=locCertTmplFont><Font Face="Arial" Size=-1><%If "Text"=sBrowser Then%><P><%Else%><BR><%End If%><Label For=lbCertTemplateID><LocID ID=locTemplateHead><B>Certificate Template:</B></LocID></Label></Font></LocID></TD>
  99.     </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  100.     </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD>
  101.     </TR><TR><TD></TD>
  102.         <TD><Select Name=lbCertTemplate ID=lbCertTemplateID>
  103. <%
  104.     Dim nWriteTemplateResult
  105.     nWriteTemplateResult=WriteTemplateList() 
  106. %>
  107.         </Select></TD>
  108.     </TR>     
  109.     <%End If%>
  110.  
  111.     <TR>
  112.         <TD ColSpan=3><LocID ID=locAttrFont><Font Face="Arial" Size=-1><%If "Text"=sBrowser Then%><P><%Else%><BR><%End If%><Label For=locTaAttrib><LocID ID=locAttribHead><B>Additional Attributes:</B></LocID></Label></Font></LocID></TD>
  113.     </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  114.     </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD>
  115.     </TR>
  116.  
  117.     <TR>
  118.         <TD Align=Right><LocID ID=locAttribLabel><Font Face="Arial" Size=-1>Attributes:</Font></LocID></TD>
  119.         <TD><TextArea ID=locTaAttrib Name=taAttrib Wrap=Off Rows=2 Cols=30></TextArea></TD>
  120.     </TR>
  121.  
  122. <%If "StandAlone"<>sServerType And 0<>nWriteTemplateResult Then%>
  123. <!-- submit button removed if there was an error getting the templates -->
  124. <%Else%>
  125.     <TR><TD ColSpan=3><Font Size=-1><BR></Font></TD></TR>
  126.     <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  127.     <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD></TR>
  128.  
  129.     <TR><TD><TD Align=Right><LocID ID=locSubmitAlign>
  130.         <Input Type=Submit ID=btnSubmit Value="Submit >" <%If "IE"=sBrowser Then%> Style="width:.75in"<%End If%>>
  131.              
  132.     </LocID></TD></TR>
  133.     <TR><TD ColSpan=3 Height=20></TD></TR>
  134. <%End If%>
  135.  
  136. </Table>
  137. <P>
  138.  
  139.  
  140. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  141. <!-- White HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#FFFFFF><Img Src="certspc.gif" Alt="" Height=5 Width=1></TD></TR></Table>
  142.  
  143. </Form>
  144. </Font>
  145. <!-- ############################################################ -->
  146. <!-- End of standard text. Scripts follow  -->
  147.     
  148. <%bIncludeXEnroll=False%>
  149. <%bIncludeGetCspList=False%>
  150. <%bIncludeTemplateCode=True%>
  151. <!-- #include FILE=certsgcl.inc -->
  152.  
  153. <!-- This form we fill in and submit 'by hand'-->
  154. <Form Name=SubmittedData Action="certfnsh.asp" Method=Post>
  155.     <Input Type=Hidden Name=Mode>             <!-- used in request ('newreq'|'chkpnd') -->
  156.     <Input Type=Hidden Name=CertRequest>      <!-- used in request -->
  157.     <Input Type=Hidden Name=CertAttrib>       <!-- used in request -->
  158.     <Input Type=Hidden Name=FriendlyType>     <!-- used on pending -->
  159.     <Input Type=Hidden Name=ThumbPrint>       <!-- used on pending -->
  160.     <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  161.     <Input Type=Hidden Name=SaveCert>         <!-- used on install ('no'|'yes')-->
  162. </FORM>
  163.  
  164. <Script Language="JavaScript">
  165.  
  166.     //----------------------------------------------------------------
  167.     // Strings to be localized
  168.     <%If "IE"=sBrowser Then%>
  169.     ;
  170.     var L_BrowseLink_Message="Browse for a file to insert";
  171.     var L_ReadProhibited_ErrorMessage="Your web browser security settings prohibit this page from accessing your disk.\nEither paste the data into this page manually, or add this page to your browser's list of trusted sites.";
  172.     var L_Unexpected_ErrorMessage="\"An unexpected error occurred while trying to read the file.\\n\\nError: \"+nResult";
  173.     var L_FileNotFound_ErrorMessage="The file you specified was not found or the drive you specified\nwas not ready. Please enter a valid file name.";
  174.     var L_NoName_ErrorMessage="Please enter a file name.";
  175.     <%End If%>
  176.     <%If "StandAlone"<>sServerType Then%>
  177.     ;
  178.     var L_TemplateLoadErrNoneFound_ErrorMessage="No certificate templates could be found. You do not have permission to request a certificate from this CA, or an error occurred while accessing the Active Directory.";
  179.     var L_TemplateLoadErrUnexpected_ErrorMessage="\"An unexpected error (\"+sErrorNumber+\") occurred while getting the certificate template list.\"";
  180.     <%End If%>
  181.     ;
  182.     var L_NoBlank_ErrorMessage="The request field may not be left blank.\n Please paste a request in the field and try again.";
  183.     var L_SavedReqCert_Text="Saved-Request Certificate";
  184.  
  185.     //================================================================
  186.     // INITIALIZATION ROUTINES
  187.  
  188.     //----------------------------------------------------------------
  189.     // This contains the functions we want executed immediately after load completes
  190.     function postLoad() {
  191.         <%If "StandAlone"<>sServerType And 0<>nWriteTemplateResult Then%>
  192.         handleLoadError(<%=nWriteTemplateResult%>, L_TemplateLoadErrNoneFound_ErrorMessage, L_TemplateLoadErrUnexpected_ErrorMessage);
  193.         <%End If%>
  194.     }
  195.  
  196.     <%If "StandAlone"<>sServerType Then%>
  197.     //----------------------------------------------------------------
  198.     // handle errors from GetTemplateList()
  199.     function handleLoadError(nResult, sNoneFound, sUnexpected) {
  200.         if (-1==nResult) {
  201.             alert(sNoneFound);
  202.         } else {
  203.             var sErrorNumber="0x"+toHex(nResult);
  204.             alert(eval(sUnexpected));
  205.         }
  206.         //document.UIForm.btnSubmit.disabled=true;
  207.     }
  208.     <%End If%>
  209.  
  210.  
  211.     <%If "IE"=sBrowser Then%>
  212.     //================================================================
  213.     // FILE READ ROUTINES
  214.  
  215.     //----------------------------------------------------------------
  216.     // IE SPECIFIC:
  217.     // make sure that we have permision to do a read, then show 
  218.     // the file name box
  219.     function BeginRead() {
  220.         if (true==TestRead()) {
  221.             spRead.style.display='';
  222.             document.UIForm.flRequest.focus()
  223.         } else {
  224.             alert(L_ReadProhibited_ErrorMessage);
  225.         }
  226.     }
  227.  
  228.     //----------------------------------------------------------------
  229.     // IE SPECIFIC:
  230.     function FinishRead() {
  231.         spnFixTxt.style.display='none';
  232.         if (""==document.UIForm.flRequest.value) {
  233.             handleReadError(5);
  234.             return;
  235.         }
  236.         var nResult=GetFileData(); // use VBScript to read the file, since it can handle errors
  237.         if (0!=nResult) {
  238.             handleReadError(nResult);
  239.             return;
  240.         }
  241.         spRead.style.display='none';
  242.         document.UIForm.btnSubmit.focus()
  243.     }
  244.  
  245.     //----------------------------------------------------------------
  246.     // IE SPECIFIC:
  247.     function handleReadError(nResult) {
  248.         var sMessage;
  249.         var elemFocusMe=null;
  250.         if (429==nResult) {
  251.             sMessage=L_ReadProhibited_ErrorMessage;
  252.             elemFocusMe=document.UIForm.flRequest;
  253.         } else if (53==nResult || 76==nResult || 71==nResult) {
  254.             sMessage=L_FileNotFound_ErrorMessage;
  255.             elemFocusMe=document.UIForm.flRequest;
  256.         } else if (5==nResult) {
  257.             sMessage=L_NoName_ErrorMessage;
  258.             elemFocusMe=document.UIForm.flRequest;
  259.         } else {
  260.             sMessage=eval(L_Unexpected_ErrorMessage);
  261.         }
  262.         
  263.         // Show the error message
  264.         alert(sMessage);
  265.  
  266.         // place focus on offending control
  267.         if (null!=elemFocusMe) {
  268.             elemFocusMe.focus();
  269.         }
  270.     }
  271.     <%End If%>
  272.  
  273.     //================================================================
  274.     // SUBMIT ROUTINES
  275.  
  276.     //----------------------------------------------------------------
  277.     // determine what to do when the submit button is pressed
  278.     function goNext() {
  279.         SubmitRequest();
  280.     }
  281.  
  282.     //----------------------------------------------------------------
  283.     // set a label to normal style
  284.     function markLabelNormal(spn) {
  285.         <%If "IE"=sBrowser Then%>
  286.         spn.style.color="#000000";
  287.         spn.style.fontWeight='normal';
  288.         <%End If%>
  289.     }
  290.  
  291.     //----------------------------------------------------------------
  292.     // set a label to error state
  293.     function markLabelError(spn) {
  294.         <%If "IE"=sBrowser Then%>
  295.         spn.style.color='#FF0000';
  296.         spn.style.fontWeight='bold';
  297.         <%End If%>
  298.     }
  299.  
  300.     //----------------------------------------------------------------
  301.     function validateRequest() {
  302.         <%If "IE"<>sBrowser Then%>
  303.         // work around for NN: label marking does nothing
  304.         var spnPasteLabel;
  305.         <%End If%>
  306.  
  307.         markLabelNormal(spnPasteLabel);
  308.                 
  309.         // Check for an empty request
  310.         if (""==document.UIForm.taRequest.value) {
  311.             bOK=false;
  312.             markLabelError(spnPasteLabel);
  313.             <%If "IE"=sBrowser Then%>
  314.             spnFixTxt.style.display='';
  315.             window.scrollTo(0,0);
  316.             <%Else%>
  317.             alert(L_NoBlank_ErrorMessage); 
  318.             <%End If%>
  319.             document.UIForm.taRequest.focus();
  320.             return false;
  321.         }
  322.  
  323.         // everything is OK
  324.         return true;
  325.     }
  326.  
  327.     //----------------------------------------------------------------
  328.     function SubmitRequest() {
  329.  
  330.         <%If "IE"=sBrowser Then%>
  331.         spnFixTxt.style.display='none';
  332.         <%End If%>
  333.  
  334.         // check that the form is filled in
  335.         if (false==validateRequest()) {
  336.             return;
  337.         }
  338.  
  339.         // set request
  340.         document.SubmittedData.CertRequest.value=document.UIForm.taRequest.value;
  341.  
  342.         // set defaults for values we need on install
  343.         document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store), but ignored when saving cert.
  344.         document.SubmittedData.SaveCert.value="yes";
  345.         document.SubmittedData.Mode.value="newreq";
  346.         document.SubmittedData.FriendlyType.value=L_SavedReqCert_Text;
  347.         // append the local date to the type
  348.         document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  349.         //not created by xenroll, not supported
  350.         document.SubmittedData.ThumbPrint.value="";
  351.  
  352.         // make sure the arributes end cr/lf
  353.         var sAttrib=document.UIForm.taAttrib.value;
  354.         if (sAttrib.lastIndexOf("\r\n")!=sAttrib.length-2 && sAttrib.length>0) {
  355.             sAttrib=sAttrib+"\r\n";
  356.         }
  357.  
  358.         <%If "Enterprise"=sServerType Then%>
  359.         // add an attribute for the cert type
  360.  
  361.         // get the selected template
  362.         var sRealName = getTemplateStringInfo(CTINFO_INDEX_REALNAME, null);
  363.  
  364.         // set the cert template
  365.         sAttrib+="CertificateTemplate:"+sRealName+"\r\n";
  366.  
  367.         <%End If%>
  368.  
  369.         // for interop debug purposes
  370.         sAttrib+="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  371.  
  372.         // set the attributes
  373.         document.SubmittedData.CertAttrib.value=sAttrib;
  374.  
  375.         // Submit the cert request and move forward in the wizard
  376.         document.SubmittedData.submit();
  377.     }
  378.  
  379. </Script>
  380.  
  381. <%If "IE"=sBrowser Then%>
  382. <Script Language="VBSCRIPT">
  383.  
  384.     '=================================================================
  385.     ' FILE READ ROUTINES
  386.  
  387.     '-----------------------------------------------------------------
  388.     ' IE SPECIFIC:
  389.     ' See if we have permision to access the file system
  390.     Function TestRead()
  391.         Dim filesystem
  392.         On Error Resume Next
  393.         
  394.         ' See if we're allowed to create the FileSystem object
  395.         Set filesystem=CreateObject("Scripting.FileSystemObject")
  396.         ' Security may not allow this
  397.         If Err.Number<>0 Then
  398.             TestRead=False
  399.         Else
  400.             TestRead=True
  401.         End If
  402.     End Function
  403.  
  404.     '-----------------------------------------------------------------
  405.     ' IE SPECIFIC:
  406.     ' read the given file into the text-area
  407.     Function GetFileData()
  408.         Dim filesystem, file
  409.         On Error Resume Next
  410.         
  411.         ' First, create the FileSystem object
  412.         Set filesystem=CreateObject("Scripting.FileSystemObject")
  413.         ' Security may not allow this
  414.         If Err.Number<>0 Then
  415.             GetFileData=Err.Number
  416.             Exit Function
  417.         End If
  418.     
  419.         ' open the specified file    
  420.         Set file=filesystem.OpenTextFile(document.UIForm.flRequest.value, 1 , false) '1->ForReading, false->don't create
  421.         ' file may not exist
  422.         If Err.Number<>0 Then
  423.             GetFileData=Err.Number
  424.             Exit Function
  425.         End If
  426.         
  427.         ' read the data and stash it into the form
  428.         document.UIForm.taRequest.value=file.ReadAll
  429.         ' catch any read errors
  430.         If Err.Number<>0 Then
  431.             GetFileData=Err.Number
  432.             Exit Function
  433.         End If
  434.         
  435.         ' clean up
  436.         file.Close
  437.         Set file=Nothing
  438.         Set filesystem=Nothing
  439.         GetFileData=0
  440.     End Function
  441.  
  442. </Script> 
  443. <%End If '"IE"=sBrowser%>
  444.  
  445. </Body>
  446. </HTML>